/*
 * File:   Box2dEngine.h
 * Author: Elevator
 *
 * Created on 24 Май 2013 г., 22:47
 */

#ifndef PHYSICS_BOX2DENGINE_H
#define PHYSICS_BOX2DENGINE_H

#include "IEngine.h"
#include "Joints/IJoint.h"
#include "Joints/IHingeJoint.h"
#include "Joints/IDistanceJoint.h"
#include "Joints/IParallelJoint.h"
#include "Bodies/IBody.h"

class b2World;

namespace physics {

	class Box2dEngine : public IEngine {
	public:
		Box2dEngine( Vec2 gravity );
		virtual ~Box2dEngine( );

		virtual IHingeJoint* CreateHingeJoint(
			IBody* bodyA, IBody* bodyB,
			const Vec2& anchor,
			bool collide,
			bool enableLimit, float leftLimit, float rightLimit,
			bool enableMotor, float motorForce, float motorSpeed );

		virtual void DestroyHingeJoint( IHingeJoint* joint );

		virtual IDistanceJoint* CreateDistanceJoint(
			IBody* bodyA, IBody* bodyB,
			const Vec2& anchorA, const Vec2& anchorB,
			bool collide,
			float length, float frequency,
			float dampingRatio );

		virtual void DestroyDistanceJoint( IDistanceJoint* joint );

		virtual IParallelJoint* CreateParallelJoint(
			IBody* bodyA, IBody* bodyB,
			const Vec2& anchor, const Vec2& axis,
			bool collide,
			bool enableLimit, float lowerLimit, float upperLimit,
			bool enableMotor, float motorForce, float motorSpeed );

		virtual void DestroyParallelJoint( IParallelJoint* joint );

		virtual IBody* CreateBody(IBody::Type type,
			const Transform& position,
			const Transform& velocity,
			float mass, float inertia );

		virtual void DestroyBody( IBody* body );

		virtual ICircleShape* CreateCircleShape( Vec2 pos, float radius );
		virtual IPolygonShape* CreatePolygonShape( Transform pos );

		virtual void Update( float dt );

	private:
		b2World* _world;
	};
}
#endif	/* BOX2DENGINE_H */

